package com.qf.index.gcrdo;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.DSFactory;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import lombok.SneakyThrows;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Author: 葛成瑞
 * @Date: 2025/4/23 13:53
 */
public class Test {
    @SneakyThrows
    public static void main(String[] args) {

        String asSSS = "\\.";

//        String as = "hjwd.djwdasd.asdwdas.。爱山东阿达爱。山东adwd。dwdasd.";
//        boolean contains = as.contains(".");
//        System.out.println(contains);
//        String[] split = as.split("。");
//        String[] split1 = as.split("\\.");
//        System.out.println(split.length);
//        System.out.println(split1.length);
//        String urlDo = "https://www.genenames.org/cgi-bin/search/suggest?query=ventxp2";
//        String urlDo = "https://pubchem.ncbi.nlm.nih.gov/#query=siberian%20ginseng%20root%20extract";
//        String s = HttpUtil.get(urlDo);
//        System.out.println(s);

        Db use = Db.use(DSFactory.get("localdb"));

        String db = "drugbanck_vocabulary";

        ExcelReader reader = ExcelUtil.getReader("F:\\drugbank vocabulary.xlsx");
        List<Map<String, Object>> maps = reader.readAll();
        for (Map<String, Object> map : maps) {

            Entity ins = new Entity();
            ins.setTableName(db);

            Set<String> strings = map.keySet();
            for (String string : strings) {
                Object o = map.get(string);
                if (o != null) {
                    if (string.equals("DrugBank ID")) {
                        ins.set("DrugBank_ID", o.toString());
                    }
                    if (string.equals("Accession Numbers")) {
                        ins.set("Accession_Numbers", o.toString());
                    }
                    if (string.equals("Common name")) {
                        ins.set("Common_name", o.toString());
                    }
                    if (string.equals("CAS")) {
                        ins.set("cas", o.toString());
                    }
                    if (string.equals("UNII")) {
                        ins.set("UNII", o.toString());
                    }
                    if (string.equals("Synonyms")) {
                        ins.set("Synonyms", o.toString());
                    }
                    if (string.equals("Standard InChI Key")) {
                        ins.set("Standard_InChI_Key", o.toString());
                    }

                }
            }
            use.insert(ins);

        }
    }
}
